<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/exam.css?v=1">
<script type="text/javascript" src="/Template/js/amazeui.js"></script>
<script type="text/javascript">


    $(function() {

        //初始化页面配置
        initPage("脊柱检测评估");

//        $("#pronationCheck input[type='checkbox']").click(function() {
//            lert(113);
//            if($(this).is(":checked")){
//                alert(123);
//            }
//        });
        $("textarea").keypress(function(e) {
            if (e.which == 13) {
                return false;
            }
        });

        if($("input[name=structure]").is(":checked")) {
            $(".structure").hide();
        } else {
            $(".structure").show();
        }
        $("input[name=structure]").click(function(){
            if($(this).is(":checked")){
                $(".structure").hide();
                $("input[name=brokenPart]").val("");
                $("input[name=broken]").get(0).checked=false;
                $("input[name=boneQuality]").removeAttr("checked");

            }else{
                $(".structure").show();
            }
        });
        if($("input[name=broken]").is(":checked")) {
            $(".checkline_first.brokenPart").show();
        } else {
            $(".checkline_first.brokenPart").hide();
        }
        $("input[name=broken]").click(function(){
            if($(this).is(":checked")){
                $(".checkline_first.brokenPart").show();
            }else{
                $(".checkline_first.brokenPart").hide();
                $("input[name=brokenPart]").val("");
            }
        });
        if($("input[name=feeling]").is(":checked")) {
            $(".feeling").hide();
        } else {
            $(".feeling").show();
        }
        $("input[name=feeling]").click(function(){
            if($(this).is(":checked")){
                $(".feeling").hide();
                $("input[name=nofeelingPart]").val("");
                $("input[name=nofeeling]").get(0).checked=false;
                $("input[name=painPart]").val("");
                $("input[name=pain]").get(0).checked=false;
            }else{
                $(".feeling").show();
            }
        });
        if($("input[name=nofeeling]").is(":checked")) {
            $(".checkline_first.nofeelingPart").show();
        } else {
            $(".checkline_first.nofeelingPart").hide();
        }
        $("input[name=nofeeling]").click(function(){
            if($(this).is(":checked")){
                $(".checkline_first.nofeelingPart").show();
            }else{
                $(".checkline_first.nofeelingPart").hide();
                $("input[name=nofeelingPart]").val("");
            }
        });
        if($("input[name=pain]").is(":checked")) {
            $(".checkline_first.painPart").show();
        } else {
            $(".checkline_first.painPart").hide();
        }
        $("input[name=pain]").click(function(){
            if($(this).is(":checked")){
                $(".checkline_first.painPart").show();
            }else{
                $(".checkline_first.painPart").hide();
                $("input[name=painPart]").val("");
            }
        });
        var app = new Vue({
            el: '#container',
            data: {
            },
            methods: {
                cancel: function() {
                    window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                },
                save: function() {
                    var examBasicSpineId = $("input[name=examBasicSpineId]").val();
                    var workorderId = $("input[name=workorderId]").val();
                    var mobility = $("select[name=mobility]").val();
                    var stand = $("select[name=stand]").val();
                    var standDescribe = $("input[name=standDescribe]").val();
                    var sit = $("select[name=sit]").val();
                    var sitDescribe = $("input[name=sitDescribe]").val();
                    var endurance = $("select[name=endurance]").val();
                    var enduranceTime = $("input[name=enduranceTime]").val();
                    var structure = $("input[name=structure]").is(":checked")? "0":"1";
                    var broken = $("input[name=broken]").is(":checked")? "1":"0";
                    var brokenPart = $("input[name=brokenPart]").val();
                    var boneQuality = $("input[name=boneQuality]:checked").val();
                    var spineGap = $("input[name=spineGap]").val();
                    var feeling = $("input[name=feeling]").is(":checked")? "0":"1";
                    var nofeeling = $("input[name=nofeeling]").is(":checked")? "1":"0";
                    var nofeelingPart = $("input[name=nofeelingPart]").val();
                    var pain = $("input[name=pain]").is(":checked")? "1":"0";
                    var painPart = $("input[name=painPart]").val();

                    var completed = "1";
                    if(isNullOrEmpty(mobility
                            && stand
                            && sit
                            && endurance)) {
                        completed = "-1";
                    }
                    if(structure != 0) {
                        if(broken == 0 && isNullOrEmpty(boneQuality && spineGap)) {
                            completed = "-1";
                        }
                    }
                    if(broken != 0 && isNullOrEmpty(brokenPart)) {
                        alert("请填写骨折节段");
                        $("input[name=brokenPart]").focus();
                        return;
                    }
                    if(feeling != 0) {
                        if(nofeeling == 0 && pain == 0) {
                            completed = "-1";
                        }
                    }
                    if(nofeeling != 0 && isNullOrEmpty(nofeelingPart)) {
                        alert("请填写感觉丧失部位");
                        $("input[name=nofeelingPart]").focus();
                        return;
                    }
                    if(pain != 0 && isNullOrEmpty(painPart)) {
                        alert("请填写疼痛部位");
                        $("input[name=painPart]").focus();
                        return;
                    }

                    $.ajax({
                        url:"/wechat/workorder/examBasicSpinePost",
                        type:"post",
                        data:{
                            examBasicSpineId: examBasicSpineId,
                            workorderId: workorderId,
                            mobility: mobility,
                            stand: stand,
                            standDescribe: standDescribe,
                            sit: sit,
                            sitDescribe: sitDescribe,
                            endurance: endurance,
                            enduranceTime: enduranceTime,
                            structure: structure,
                            broken: broken,
                            brokenPart: brokenPart,
                            boneQuality: boneQuality,
                            spineGap: spineGap,
                            feeling: feeling,
                            nofeeling: nofeeling,
                            nofeelingPart: nofeelingPart,
                            pain: pain,
                            painPart: painPart,

                            completed:completed,
                        },
                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
//                                alert(data.alert);
                                alert("保存成功");
                                window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                            }
                        },
                    })

                }
            }
        })
        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });
    })

</script>

<div class="container" id="container">
    <div class="hint-info">
        <span class="update_time">{$formDict.update_time}：{$examBasicSpine.update_time}</span>
        <span class="employee_name">{$formDict.update_name}：{$employeeName}</span>
    </div>
    <div class="edit-info">
        <div class="edit-content" >
            <input type="text" style="display: none;" name="workorderId" value="{$workorderId}">
            <input type="text" style="display: none;" name="examBasicSpineId" value="{$examBasicSpineId}">
            <div class="item">
                <span>行动能力：</span>
                <php>
                    $mobilityName = $formDict["mobility_".$examBasicSpine["mobility"]];
                </php>
                <input id="mobility" type="text" value="{$mobilityName}" readonly placeholder="请选择">
                <select name="mobility">
                    <option value="{$examBasicSpine.mobility}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasicSpine['mobility'],'mobility','exam_basic_spine',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item" style="border-bottom:0px">
                <span>站立平衡：</span>
                <php>
                    $standName = $formDict["stand_".$examBasicSpine["stand"]];
                </php>
                <input id="stand" type="text" value="{$standName}" readonly placeholder="请选择">
                <select name="stand">
                    <option value="{$examBasicSpine.stand}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasicSpine['stand'],'stand','exam_basic_spine',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item"><span>描述：</span><input name="standDescribe" type="text" value="{$examBasicSpine.stand_describe}" placeholder="请输入"></div>

            <div class="item" style="border-bottom:0px">
                <span>坐位姿势：</span>
                <php>
                    $sitName = $formDict["sit_".$examBasicSpine["sit"]];
                </php>
                <input id="sit" type="text" value="{$sitName}" readonly placeholder="请选择">
                <select name="sit">
                    <option value="{$examBasicSpine.sit}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasicSpine['sit'],'sit','exam_basic_spine',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item"><span>描述：</span><input name="sitDescribe" type="text" value="{$examBasicSpine.sit_describe}" placeholder="请输入"></div>

            <div class="item" style="border-bottom:0px">
                <span>坐位耐受能力：</span>
                <php>
                    $enduranceName = $formDict["endurance_".$examBasicSpine["endurance"]];
                </php>
                <input id="endurance" type="text" value="{$enduranceName}" readonly placeholder="请选择">
                <select name="endurance">
                    <option value="{$examBasicSpine.endurance}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasicSpine['endurance'],'endurance','exam_basic_spine',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item"><span>坐位持续时间：</span><input name="enduranceTime" type="text" value="{$examBasicSpine.endurance_time}" placeholder="请输入"></div>

            <div class="item">
                <span class="itemTitle" style="margin-left: 30%">—— 主要损伤 ——</span><br/>
            </div>
            <div class="item" style="border-bottom:0px">
                <span>A.结构：</span>
                <div class="checkline_first">
                    <php>
                        if($examBasicSpine["structure"] == "0"){
                            $structure = "checked";
                        }
                    </php>
                    <input name="structure" class="checkFirst" value="0" type="checkbox"  {$structure}>无损伤
                </div>
            </div>
            <div class="structure">
                <div class="item" style="border-bottom:0px">
                    <span>1.骨骼：</span>
                    <div class="checkline_first brokenPart" style="display: none">
                        节段：<input name="brokenPart" id="brokenPart" class="part" type="text"
                                  value="{$examBasicSpine.broken_part}" placeholder="请输入">
                    </div>
                    <div class="checkline_first">
                        <php>
                            if($examBasicSpine["broken"] == "1"){
                            $broken = "checked";
                            }
                        </php>
                        <input name="broken" class="checkFirst" value="0" type="checkbox"  {$broken}>骨折
                    </div>
                </div>
                <div class="item" style="border-bottom:0px">
                    <div class="checkline_second">
                        <php>
                            $boneQuality[$examBasicSpine["bone_quality"]] = "checked";
                        </php>
                        <input name="boneQuality" class="checkFirst" value="0" type="radio" {$boneQuality[0]}>骨量减少
                        <input name="boneQuality" class="checkOther" value="1" type="radio" {$boneQuality[1]}>骨质疏松
                        <input name="boneQuality" class="checkOther" value="2" type="radio" {$boneQuality[2]}>严重骨质疏松
                    </div>
                </div>
                <div class="item"><span>2.椎间隙（描述）：</span><input name="spineGap" type="text" value="{$examBasicSpine.spine_gap}" placeholder="请输入"></div>
            </div>

            <div class="item" style="border-bottom:0px">
                <span>B.感觉：</span>
                <div class="checkline_first">
                    <php>
                        if($examBasicSpine["feeling"] == "0"){
                            $feeling = "checked";
                        }
                    </php>
                    <input name="feeling" class="checkFirst" value="0" type="checkbox"  {$feeling}>无损伤
                </div>
            </div>
            <div class="feeling">
                <div class="item" style="border-bottom:0px">
                    <div class="checkline_first nofeelingPart" style="display: none">
                        部位：<input name="nofeelingPart" id="nofeelingPart" class="part" type="text"
                                  value="{$examBasicSpine.nofeeling_part}" placeholder="请输入">
                    </div>
                    <div >
                        <php>
                            if($examBasicSpine["nofeeling"] == "1"){
                            $nofeeling = "checked";
                            }
                        </php>
                        <input name="nofeeling" class="checkFirst" value="0" type="checkbox"  {$nofeeling}>1.感觉丧失
                    </div>
                </div>
                <div class="item" style="border-bottom:0px">
                    <div class="checkline_first painPart" style="display: none">
                        部位：<input name="painPart" id="painPart" class="part" type="text"
                                    value="{$examBasicSpine.pain_part}" placeholder="请输入">
                    </div>
                    <div>
                        <php>
                            if($examBasicSpine["pain"] == "1"){
                            $pain = "checked";
                            }
                        </php>
                        <input name="pain" class="checkFirst" value="0" type="checkbox"  {$pain}>2.疼痛
                    </div>
                </div>
            </div>

        </div>

    </div>
    <div class="operation-btn">
        <div class="cancle-btn" v-on:click="cancel">取消</div>
        <if condition="$workorder['status'] eq '-1' && $workorder['creator_id'] eq $customerId">
           <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <if condition="$workorder['status'] eq '2' && $workorder['examinator_id'] eq $customerId">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <if condition="$workorder['status'] gt '2' && $job[0] eq 100">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
    </div>

</div>
<include file="./Template/footer.html" />